<ui:composition xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j">
    <h:form>
        <h:panelGrid columns="2">

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.number}"/></ui:define>
                <h:inputText id="number" required="false" requiredMessage="#{messages.requiedMessage}"
                             value="#{contactPersonBean.entity.number}" rendered="#{contactPersonBean.editField}"/>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="number"/>
                <ui:param name="value" value="#{contactPersonBean.entity.number}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.fullName}"/></ui:define>
                <h:inputText id="fullName" required="true" requiredMessage="#{messages.requiedMessage}"
                             value="#{contactPersonBean.entity.fullName}" rendered="#{contactPersonBean.editField}">
                    <a4j:support event="onblur"/>
                </h:inputText>
                <ui:param name="required" value="true"/>
                <ui:param name="idInput" value="fullName"/>
                <ui:param name="value" value="#{contactPersonBean.entity.fullName}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.sex}"/></ui:define>
                <h:selectOneMenu id="sex" required="false" requiredMessage="#{messages.requiedMessage}"
                                 value="#{contactPersonBean.entity.sex}" rendered="#{contactPersonBean.editField}">
                    <f:selectItems value="#{contactPersonBeanController.sexSelectItems}"/>
                    <f:converter converterId="sexEnumConverter"/>
                </h:selectOneMenu>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="sex"/>
                <ui:param name="value" value="#{contactPersonBean.entity.sex}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
                <ui:param name="myConverter" value="#{enumAsStringConverterBean}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.dateBirth}"/></ui:define>
                <rich:calendar id="dateBirth" required="false" requiredMessage="#{messages.requiedMessage}"
                               value="#{contactPersonBean.entity.dateBirth}" rendered="#{contactPersonBean.editField}"/>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="dateBirth"/>
                 <ui:param name="value" value="#{contactPersonBean.entity.dateBirth}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
                <ui:param name="myConverter" value="#{baseDateConverterBean}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.email}"/></ui:define>
                <h:inputText id="email" required="false" requiredMessage="#{messages.requiedMessage}"
                             value="#{contactPersonBean.entity.email}" rendered="#{contactPersonBean.editField}">
                    <f:validator validatorId="emailValidator"/>
                </h:inputText>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="email"/>
                 <ui:param name="value" value="#{contactPersonBean.entity.email}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.additionalEmail}"/></ui:define>
                <h:inputText id="additionalEmail" required="false" requiredMessage="#{messages.requiedMessage}"
                             value="#{contactPersonBean.entity.additionalEmail}" rendered="#{contactPersonBean.editField}">
                    <f:validator validatorId="emailValidator"/>
                </h:inputText>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="additionalEmail"/>
                 <ui:param name="value" value="#{contactPersonBean.entity.additionalEmail}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>


            <ui:insert name="customerField"/>

            <!--<ui:decorate template="../../layout/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.organization}"/></ui:define>
                <h:selectOneMenu id="organization" required="true" requiredMessage="#{messages.requiedMessage}"
                                 value="#{contactPersonBeanController.entity.customer}">
                    <f:selectItems value="#{customerBeanController.selectList}"/>
                    <f:converter converterId="customerConverter"/>
                </h:selectOneMenu>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="organization"/>
            </ui:decorate>-->

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.isMain}"/></ui:define>
                <h:selectBooleanCheckbox id="main" required="false" requiredMessage="#{messages.requiedMessage}"
                                         value="#{contactPersonBean.entity.main}" />
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="main"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.position}"/></ui:define>
                <h:inputText id="position" required="false" requiredMessage="#{messages.requiedMessage}"
                             value="#{contactPersonBean.entity.position}" rendered="#{contactPersonBean.editField}"/>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="position"/>
                 <ui:param name="value" value="#{contactPersonBean.entity.position}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.workPhone}"/></ui:define>
                <h:inputText id="workPhone" required="false" requiredMessage="#{messages.requiedMessage}"
                             value="#{contactPersonBean.entity.workPhone}" rendered="#{contactPersonBean.editField}"/>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="workPhone"/>
                 <ui:param name="value" value="#{contactPersonBean.entity.workPhone}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.mobilePhone}"/></ui:define>
                <h:inputText id="mobilePhone" required="false" requiredMessage="#{messages.requiedMessage}"
                             value="#{contactPersonBean.entity.mobilePhone}" rendered="#{contactPersonBean.editField}"/>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="mobilePhone"/>
                 <ui:param name="value" value="#{contactPersonBean.entity.mobilePhone}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.roles}"/></ui:define>
                <!--<rich:pickList id="rolesPhone" required="true" requiredMessage="#{messages.requiedMessage}"
                    value="#{contactPersonBeanController.contactPerson.roles}">
                    <f:selectItems value="#{roleBeanController.availableRoles}"/>
                </rich:pickList>-->
                <h:selectManyCheckbox id="roles" value="#{contactPersonBean.entity.roles}" rendered="#{contactPersonBean.editField}">
                    <f:selectItems value="#{roleBeanController.selectList}"/>
                    <f:converter converterId="roleConverter"/>
                </h:selectManyCheckbox>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="roles"/>
                <ui:param name="value" value="#{contactPersonBean.entity.roles}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
            </ui:decorate>

            <ui:decorate template="../common/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages.dateLastContact}"/></ui:define>
                <rich:calendar id="dateLastContact" required="false" requiredMessage="#{messages.requiedMessage}"
                               value="#{contactPersonBean.entity.dateLastContact}" rendered="#{contactPersonBean.editField}"/>
                <ui:param name="required" value="false"/>
                <ui:param name="idInput" value="dateLastContact"/>
                <ui:param name="value" value="#{contactPersonBean.entity.dateLastContact}"/>
                <ui:param name="editField" value="#{contactPersonBean.editField}"/>
                <ui:param name="myConverter" value="#{baseDateConverterBean}"/>
            </ui:decorate>

        </h:panelGrid>

        <ui:insert name="buttons"/>

    </h:form>
</ui:composition>